﻿// CheckItemPropertyGridCtrl.cpp: 实现文件
//

#include "stdafx.h"
#include "zChecker.h"
#include "CheckItemPropertyGridCtrl.h"


// CCheckItemPropertyGridCtrl

IMPLEMENT_DYNAMIC(CCheckItemPropertyGridCtrl, CMFCPropertyGridCtrl)

CCheckItemPropertyGridCtrl::CCheckItemPropertyGridCtrl()
{
	m_pItem = NULL;
}

CCheckItemPropertyGridCtrl::~CCheckItemPropertyGridCtrl()
{
	if (m_pItem)
	{
		m_pItem->Release();
		m_pItem = NULL;
	}
}


BEGIN_MESSAGE_MAP(CCheckItemPropertyGridCtrl, CMFCPropertyGridCtrl)
END_MESSAGE_MAP()



// CCheckItemPropertyGridCtrl 消息处理程序


void CCheckItemPropertyGridCtrl::Populate(ck::CheckItem* pItem)
{
	RemoveAll();

	if (m_pItem)
	{
		m_pItem->Release();
		m_pItem = NULL;
	}

	m_pItem = pItem;

	PopulateCode();
	PopulateProperty();
	PopulateOther();

}

void CCheckItemPropertyGridCtrl::PopulateCode()
{
	CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(_T("系统属性"));	

	const char* szItemCode = m_pItem->GetCodeString();
	char szElemCode[_MAX_FNAME];
	char szSubECode[_MAX_FNAME];
	ck::CheckElement::GetElementCode(szElemCode, _MAX_FNAME, szItemCode);
	ck::CheckElement::GetSubElementCode(szSubECode, _MAX_FNAME, szItemCode);


	pGroup->AddSubItem(new CMFCPropertyGridProperty("检查项编码", (_variant_t)szItemCode, _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("质量子元素编码", (_variant_t)szSubECode, _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("标准检查项编码", (_variant_t)szElemCode, _T("")));

	AddProperty(pGroup);
}

void CCheckItemPropertyGridCtrl::PopulateProperty()
{
	const char* szName = m_pItem->GetName();
	const char* szDescription = m_pItem->GetDescription();

	CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(_T("基本属性"));

	pGroup->AddSubItem(new CMFCPropertyGridProperty("名称", (_variant_t)szName, _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("描述", (_variant_t)szDescription, _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("计分方式", (_variant_t)"", _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("分组", (_variant_t)"", _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("权值", (_variant_t)"", _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("结果枚举", (_variant_t)"", _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("限差值", (_variant_t)"", _T("")));

	AddProperty(pGroup);
}

void CCheckItemPropertyGridCtrl::PopulateOther()
{
	CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(_T("基本属性"));

	pGroup->AddSubItem(new CMFCPropertyGridProperty("名称", (_variant_t)"", _T("")));

	AddProperty(pGroup);
}


void CCheckItemPropertyGridCtrl::Init2()
{
	CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(_T("系统属性"));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("检查项编码", (_variant_t)"", _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("质量子元素编码", (_variant_t)"", _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("标准检查项编码", (_variant_t)"", _T("")));
	AddProperty(pGroup);

	pGroup = new CMFCPropertyGridProperty(_T("基本属性"));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("名称", (_variant_t)"", _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("描述", (_variant_t)"", _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("计分方式", (_variant_t)"", _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("分组", (_variant_t)"", _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("权值", (_variant_t)"", _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("结果枚举", (_variant_t)"", _T("")));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("限差值", (_variant_t)"", _T("")));
	AddProperty(pGroup);

	pGroup = new CMFCPropertyGridProperty(_T("基本属性"));
	pGroup->AddSubItem(new CMFCPropertyGridProperty("名称", (_variant_t)"", _T("")));
	AddProperty(pGroup);

}